﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Medical.Business;
using System.Text;

public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            DataTable dtAd = Until.GetWebBanner();
            if (dtAd != null && dtAd.Rows.Count > 0)
            {
                DataRow[] drList = dtAd.Select("OrderNum=0");
                if (drList.Length > 0)
                {
                    imgHead.ImageUrl = "/" + WebConfigInfo.FilePlace + "d/" + drList[0]["ImgPlace"].ToString();
                }
            }

            InitData();
        }
    }

    /// <summary>
    /// 加载数据
    /// </summary>
    protected void InitData()
    {
        StringBuilder sbHtml = new StringBuilder();
        DataTable dt = Common.GetDiseaseSort();
        DataRow[] drList = dt.Select("ParentID=0");
        string strUrlName = string.Empty;
        for (int i = 0; i < drList.Length; i++)
        {
            if (i == 6)
                break;
            strUrlName = drList[i]["PageUrlName"].ToString();
            if (i == 5)
            {
                sbHtml.Append("<li class=\"nobord\">");
            }
            else
            {
                sbHtml.Append("<li>");
            }
            sbHtml.Append("<h3><a href=\"/" + drList[i]["PageUrlName"].ToString() + "/\" target=\"_blank\" title=\"" + drList[i]["Name"].ToString() + "\">" + Server.HtmlEncode(drList[i]["Name"].ToString()) + "</a></h3>");
            sbHtml.Append("<p>");
            DataRow[] drSubList = dt.Select("ParentID=" + drList[i]["ID"].ToString());
            for (int j = 0; j < drSubList.Length; j++)
            {
                if (j == 4)
                    break;
                sbHtml.Append("<a href=\"/" + strUrlName + "/" + drSubList[j]["PageUrlName"].ToString() + "/\" title=\"" + drSubList[j]["Name"].ToString() + "\" target=\"_blank\">" + Server.HtmlEncode(drSubList[j]["Name"].ToString()) + "</a>");
            }
            sbHtml.Append("</p></li>");
        }
        sortmenu.InnerHtml = sbHtml.ToString();
    }
}
